package nothing.dao.hibernate;

import java.sql.Date;
import nothing.model.Diary;
import nothing.dao.DiaryDao;
import org.appfuse.dao.hibernate.GenericDaoHibernate;

import java.util.List;

public class DiaryDaoHibernate extends GenericDaoHibernate<Diary, Long> implements DiaryDao {

    public DiaryDaoHibernate() {
        super(Diary.class);
    }

    @SuppressWarnings("unchecked")
    public List<Diary> findByDate(Date date) {
        return getHibernateTemplate().find("from Diary d where d.when=?", date);
    }

    @SuppressWarnings("unchecked")
    public List findByName(String name) {
        return getHibernateTemplate().find("from Recipe r, Diary d where d.recipe=r and r.name=?", name);
    }
}
